if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_Sjzc_synchronization_tableSize]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
-- 删除存储过程 
drop procedure [dbo].[sp_Sjzc_synchronization_tableSize] 
GO 
/****** Object:  StoredProcedure [dbo].[sp_Sjzc_synchronization_tableSize]    Script Date: 08/21/2019 16:47:15 ******/
   
CREATE PROCEDURE [dbo].[sp_Sjzc_synchronization_tableSize] 
	@tableName varchar(64)
AS
/**********  
[版本号]1.0.0.0    
[创建时间]2019-08-16    
[作者]wjx    
[版权]copyright-上海金仕达卫宁软件股份有限公司    
[描述]    
[功能说明]查询指定的表的记录数和表空间大小 索引大小
[返回值]    
[结果集、排序]    
[调用的usp]    
[调用实例] exec sp_Sjzc_synchronization_tableSize '表名'
**********/
BEGIN
	set nocount on
	if exists(select 1 from tempdb..sysobjects where id=object_id('tempdb..#tabName') and xtype='u')
	BEGIN
		drop table #tabName
	END
	create table #tabName(
		tabname varchar(100),
		rowsNum varchar(100),
		reserved varchar(100),
		data varchar(100),
		index_size varchar(100),
		unused_size varchar(100)
	)
	begin
		insert into #tabName
			EXEC sp_spaceused @updateusage = N'TRUE',@objname=@tableName
	end
		 select tabname as '表名',rowsNum as '表数据行数',reserved as '保留大小',data as '数据大小',index_size as '索引大小',unused_size as '未使用大小'
		from #tabName
		--where tabName='JB_XMML'
		order by cast(rowsNum as int) desc
		
END
